import time
from Common.Base import Base,open_browser

'''
Author:牟星林
'''

register_page_url = ("http://localhost:8080/Ecshop/user.php?act=register")
class Register(Base):
    username_reg = ("id","username")
    email_reg = ("id","email")
    password_reg = ("id","password1")
    confirm_password = ("id","conform_password")
    phone_reg = ("name","extend_field5")
    submit_reg = ("name", "Submit")

# 操作层
    def input_username(self,username):
        '''
        输入注册用户名
        :param username:
        :return:
        '''
        self.send_keys(self.username_reg,username)

    def input_email(self,email):
        '''
        输入注册邮箱
        :param username:
        :return:
        '''
        self.send_keys(self.email_reg,email)

    def input_password(self,password):
        '''
        输入注册密码
        :param username:
        :return:
        '''
        self.send_keys(self.password_reg,password)

    def input_confirm_password(self,confirm_password):
        '''
        确认注册密码
        :param username:
        :return:
        '''
        self.send_keys(self.confirm_password,confirm_password)

    def input_phone_reg(self,phone):
        '''
        输入手机号
        :param username:
        :return:
        '''
        self.send_keys(self.phone_reg,phone)

    def click_submit_reg(self):
        '''
        点击注册
        :param username:
        :return:
        '''
        self.click(self.submit_reg)

if __name__ == '__main__':
    diver = open_browser()
    register = Register(diver)
    register.open_url("http://localhost:8080/Ecshop/user.php?act=register") # 注册网址
    time.sleep(1)
    diver.maximize_window()

    register.input_username("muxinglin1") # 输入用户名
    time.sleep(1)

    register.input_email("18875071279@163.com") # 输入邮箱
    time.sleep(1)

    register.input_password("mxl123456") # 输入密码
    time.sleep(1)

    register.input_confirm_password("mxl123456") # 输入确认密码
    time.sleep(1)

    register.input_phone_reg(13500351194) # 输入手机号
    time.sleep(1)


    register.click_submit_reg() # 点击注册

    time.sleep(2)
    register.close_browser()
